from rest_framework import serializers

from apps.goods.models import SpecificationOption,SPUSpecification


class SpecificationOptionSerializer(serializers.ModelSerializer):
    """
    规格选项表序列化器
    """
    # 关联嵌套返回SPU规格名称
    spec = serializers.StringRelatedField(read_only=True)
    # 关联嵌套返回SPU规格ID
    spec_id = serializers.IntegerField()

    class Meta:
        model = SpecificationOption
        fields = "__all__"



class SPUSpecificationSerializer(serializers.ModelSerializer):
    """
    规格表序列化器
    """

    class Meta:
        model = SPUSpecification
        fields = "__all__"